<?php
  require(dirname(__FILE__)."/../RequestMethod.php");
  require(dirname(__FILE__)."/../model/UserModel.php");
  class ResolveController extends RequestMethod{
      private $userModel = null;
      /**
      *构造函数，实例化对象
      */
      public function __construct($urlArr){
          $this->userModel = new UserModel();
          parent::__construct($urlArr);
      }
      /**
      *GET请求
      */
      public function doGet(){
        $action = $_GET['action'];
      }
      /**
      *POST请求
      */
      public function doPost(){
        $action = $_GET['action'];
          switch ($action) {
            case 'list':
              $termArr = $_POST['term'];
              $result=$this->userModel->findUserList($termArr);
              break;
            case 'add':
              $user = $_POST['user'];
              $result = $this->userModel->addUser($user);
              break;
            case 'mod':
              $user = $_POST['user'];
              $result = $this->userModel->update($user);
              break;
            case 'checkUser':
              $userName = $_POST['userName'];
              $result = $this->userModel->checkUser($userName);
              break;
            case 'status':
              $status = $_POST['status'];
              $result = $this->userModel->changeUserStatus($status);
              break;
            case 'passWord':
              $userId = $_POST['userId'];
              $passWord = $_POST['passWord'];
              $result = $this->userModel->changePassWord($userId,$passWord);
              break;
          }
        echo json_encode($result);
      }
  }
?>
